home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / JZTIMER.C < prev    next >
Text File  |  1989-04-09  |  775b  |  19 lines

  1. /* timer.c - use BIOS time-of-day interrupt */
  2. static long stime ;               /* time-of-day from last call*/
  3.  
  4. int jztimer()                 /* count elapsed time since */
  5.  {                       /* last call (in ticks) */
  6.     struct REGS sreg , dreg ;
  7.     long etime , delta ;
  8.  
  9.     sreg.x.ax = 0 ;             /* operation = get time count */
  10.     int86(0x1a,&sreg,&dreg);        /* do software interrupt */
  11.                        /* assemble 32-bit TOD value */
  12.     etime = ( ((long) dreg.x.cx) << 16 ) + dreg.x.dx;
  13.     delta = etime - stime ;
  14.     if( (dreg.x.ax & 0xff) != 0)       /* new day since last call? */
  15.     delta = delta + 0x01800B0L ;   /* yes-add 1 day in ticks*/
  16.     stime = etime ;               /* save TOD for next call */
  17.     return( (int) (delta / 18 )) ;          /* return as an integer */
  18.  }
  19.